from cms import Cms

def display_menu():
    while True:
        print("""
            -----------------欢迎来到客户端里系统-----------------
                                1. 添加客户
                                2. 删除客户
                                3. 修改客户
                                4. 查询客户
                                5. 显示客户
                                6. 退出
        """)

        match input("请输入您的选择："):
            case "1":
                if c_id := cms.add_customer():
                    print(f"添加成功，客户id为：{c_id}")
            case "2":
                c_id = input("请输入要删除的客户id")
                if cms.remove_customer(c_id):
                    print("删除成功")
            case "3":
                if cms.update_customer():
                    print("修改成功")
            case "4":
                c_id = input("请输入要查询的客户id")
                print(customer if (customer := cms.search_customer(c_id)) is not None else "客户不存在")
            case "5":
                customers = cms.show_customers()
                [print(customer) for customer in customers.values()]
            case "6":
                print("退出")
                break
            case _:
                print("输入错误")

if __name__ == '__main__':
    cms = Cms()
    display_menu()